﻿<Window x:Class="SSATool.UI.View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:tb="http://www.hardcodet.net/taskbar"
        Title="Simple Service Administration Tool" Height="310" Width="440" Icon="/ssatool;component/Icons/app.ico"
        ResizeMode="CanMinimize"
        xmlns:ssat="clr-namespace:SSATool.UI.View.Converters" StateChanged="OnWindowStateChanged" WindowStyle="SingleBorderWindow">
    <Window.Resources>
        <ssat:BoolNegationConverter x:Key="boolNegationConverter" />
        <ssat:StopEnabledServiceConverter x:Key="stopEnabledServiceConverter" />
        <ssat:StartEnabledServiceConverter x:Key="startEnabledServiceConverter" />
        <ssat:ContinueEnabledServiceConverter x:Key="continueEnabledServiceConverter" />
        <ssat:PauseEnabledServiceConverter x:Key="pauseEnabledServiceConverter" />
        <ssat:NotifyIconServiceConverter x:Key="notifyIconServiceConverter" />
    </Window.Resources>
    <Grid HorizontalAlignment="Stretch">
        <tb:TaskbarIcon
              x:Name="_tbiNotifyIcon"
              IconSource="{Binding ElementName=_dgdServices, Path=SelectedItem, Converter={StaticResource notifyIconServiceConverter}, Mode=OneWay}"
              ToolTipText="Simple Service Administration Tool" TrayMouseDoubleClick="OnApplicationShow">
            <tb:TaskbarIcon.ContextMenu>
                <ContextMenu Name="_ctxNotifyIcons">
                    <MenuItem Header="Show Application" Click="OnApplicationShow" FontWeight="Bold" />
                    <Separator />
                    <MenuItem Header="Start Service" Click="OnStartButtonClick" IsEnabled="{Binding ElementName=_dgdServices, Path=SelectedItem, Converter={StaticResource startEnabledServiceConverter}, Mode=OneWay}" />
                    <MenuItem Header="Stop Service" Click="OnStopButtonClick" IsEnabled="{Binding ElementName=_dgdServices, Path=SelectedItem, Converter={StaticResource stopEnabledServiceConverter}, Mode=OneWay}" />
                    <Separator />
                    <MenuItem Header="Close Application" Click="OnApplicationClose" />
                </ContextMenu>
            </tb:TaskbarIcon.ContextMenu>
        </tb:TaskbarIcon>
        <TabControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="_tbcMainWindow" Padding="0" TabStripPlacement="Bottom">
            <TabItem Header="Connection" Name="_tbmConnection">
                <Grid Background="White">
                    <Image Height="92" HorizontalAlignment="Stretch" Name="_imgHeader" Stretch="Fill" VerticalAlignment="Top" Source="/ssatool;component/Icons/header.jpg" />
                    <Label Content="Computer:" Height="28" HorizontalAlignment="Left" Margin="29,111,0,0" Name="_lblComputer" VerticalAlignment="Top" Width="114" />
                    <Label Content="User Name:" Height="28" HorizontalAlignment="Left" Margin="29,145,0,0" Name="_lblUserName" VerticalAlignment="Top" Width="114" />
                    <Label Content="Password:" Height="28" HorizontalAlignment="Left" Margin="29,179,0,0" Name="_lblPassword" VerticalAlignment="Top" Width="114" />
                    <TextBox Height="23" HorizontalAlignment="Right" Margin="0,113,40,0" Name="_tbxComputer" VerticalAlignment="Top" Width="233" IsEnabled="{Binding Path=Connection.IsConnected, Converter={StaticResource boolNegationConverter}}" Text="localhost" />
                    <TextBox Height="23" HorizontalAlignment="Right" Margin="0,147,40,0" Name="_tbxUserName" VerticalAlignment="Top" Width="233" IsEnabled="{Binding Path=Connection.IsConnected, Converter={StaticResource boolNegationConverter}}" />
                    <PasswordBox Height="23" HorizontalAlignment="Right" Margin="0,181,40,0" Name="_tbxPassword" VerticalAlignment="Top" Width="233" IsEnabled="{Binding Path=Connection.IsConnected, Converter={StaticResource boolNegationConverter}}" />
                    <Button Content="Connect" Height="23" HorizontalAlignment="Left" Margin="301,209,0,0" Name="_btnConnect" VerticalAlignment="Top" Width="75" IsEnabled="{Binding Path=Connection.IsConnected, Converter={StaticResource boolNegationConverter}}" Click="OnConnectButtonClick" IsDefault="True" />
                    <Label Height="23" HorizontalAlignment="Left" Margin="29,209,0,0" Name="_lblError" VerticalAlignment="Top" Width="263" Foreground="Red" />
                </Grid>
            </TabItem>
            <TabItem Header="Services" Name="_tbmServices" IsSelected="{Binding Path=Connection.IsConnected, Mode=OneWay}" IsEnabled="{Binding Path=Connection.IsConnected}">
                <Grid>
                    <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Path=Services, Mode=OneWay}" Height="213" HorizontalAlignment="Stretch" Padding="0,0,0,0" Name="_dgdServices" VerticalAlignment="Top" SelectionMode="Single">
                        <DataGrid.Columns>
                            <DataGridTextColumn Width="2*" Header="Name" Binding="{Binding Path=ServiceName, Mode=OneWay}" />
                            <DataGridTextColumn Width="1*" Header="State" Binding="{Binding Path=Status, Mode=OneWay}" />
                            <DataGridTextColumn Width="3*" Header="Description" Binding="{Binding Path=DisplayName, Mode=OneWay}" />
                        </DataGrid.Columns>
                    </DataGrid>
                    <Button Content="Stop" Height="23" HorizontalAlignment="Left" Margin="335,218,0,0" Name="_btnStop" VerticalAlignment="Top" IsEnabled="{Binding ElementName=_dgdServices, Path=SelectedItem, Converter={StaticResource stopEnabledServiceConverter}, Mode=OneWay}" Width="75" Click="OnStopButtonClick" />
                    <Button Content="Start" Height="23" HorizontalAlignment="Left" Margin="254,218,0,0" Name="_btnStart" VerticalAlignment="Top" IsEnabled="{Binding ElementName=_dgdServices, Path=SelectedItem, Converter={StaticResource startEnabledServiceConverter}, Mode=OneWay}" Width="75" Click="OnStartButtonClick" />
                    <Button Content="Pause" Height="23" HorizontalAlignment="Left" Margin="173,218,0,0" Name="_btnPause" VerticalAlignment="Top" IsEnabled="{Binding ElementName=_dgdServices, Path=SelectedItem, Converter={StaticResource pauseEnabledServiceConverter}, Mode=OneWay}" Width="75" Click="OnPauseButtonClick" />
                    <Button Content="Continue" Height="23" HorizontalAlignment="Left" Margin="92,218,0,0" Name="_btnContinue" VerticalAlignment="Top" IsEnabled="{Binding ElementName=_dgdServices, Path=SelectedItem, Converter={StaticResource continueEnabledServiceConverter}, Mode=OneWay}" Width="75" Click="OnContinueButtonClick" />
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
